//
//  HSCToolController.m
//  Bigeyes
//
//  Created by 红沙尘 on 17/6/15.
//  Copyright © 2017年 uShareit. All rights reserved.
//

#import "HSCToolController.h"
#import "LogViewController.h"
#import "VersionViewController.h"

@interface HSCToolController ()<UITableViewDataSource,UITableViewDelegate>
{
    __weak IBOutlet UITableView *myTableView;
    NSArray *listArray;
}

@end

@implementation HSCToolController

- (void)viewDidLoad {
    [super viewDidLoad];
    listArray = @[@"Version",@"API Log"];
    
    myTableView.rowHeight = 45;
    myTableView.estimatedRowHeight = 45;
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    btn.frame = CGRectMake(0, 0, 44, 44);
    [btn setTitle:@"关闭" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
}

- (void)close {
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return listArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HSCToolCell"];
    
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:0 reuseIdentifier:@"HSCToolCell"];
    }
    
    cell.textLabel.text = listArray[indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    switch (indexPath.row) {
        case 0:
        {
            [self.navigationController pushViewController:[[VersionViewController alloc] init] animated:YES];
        }
            break;
        case 1:
        {
            [self.navigationController pushViewController:[[LogViewController alloc] init] animated:YES];
        }
            break;
        default:
            break;
    }
}

@end
